package com.sec.android.app.myfiles.module.download.download;

import android.app.DownloadManager;

import com.sec.android.app.myfiles.info.FileType;
import com.sec.android.app.myfiles.module.download.DownloadFileRecord;

import junit.framework.Assert;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class testDownloadFileRecord {
    private DownloadFileRecord mNullRecord;
    private DownloadFileRecord mBrowserRecord;
    private DownloadFileRecord mEmailRecord;

    private static final String sDescription = "myDescription";

    @Before
    public void setUp() throws Exception {
        mNullRecord = new DownloadFileRecord(0, 0, "/test", "test", 0, 0, FileType.UNKNOWN, "http://test/test", null, DownloadManager.STATUS_SUCCESSFUL, DownloadFileRecord.DownloadType.DOWNLOAD_BY_BROWSER.ordinal());
        mBrowserRecord = new DownloadFileRecord(0, 0, "/test", "test", 0, 0, FileType.UNKNOWN, "http://test/test", sDescription, DownloadManager.STATUS_SUCCESSFUL, DownloadFileRecord.DownloadType.DOWNLOAD_BY_BROWSER.ordinal());
        mEmailRecord = new DownloadFileRecord(0, 0, "/test", "test", 0, 0, FileType.UNKNOWN, "http://test/test", DownloadFileRecord.EMAIL_DESCRIPTION_HEADER + sDescription, DownloadManager.STATUS_SUCCESSFUL, DownloadFileRecord.DownloadType.DOWNLOAD_BY_BROWSER.ordinal());
    }

    @After
    public void tearDown() throws Exception {

    }

    @Test
    public void testGetDescription() {
        Assert.assertNull(mNullRecord.getDescription());
        Assert.assertEquals(sDescription, mBrowserRecord.getDescription());
        Assert.assertEquals(sDescription, mEmailRecord.getDescription());
    }

    @Test
    public void testDownloadedByEmail() {
        Assert.assertFalse(mNullRecord.isDownloadedByEmail());
        Assert.assertFalse(mBrowserRecord.isDownloadedByEmail());
        Assert.assertTrue(mEmailRecord.isDownloadedByEmail());
    }

}
